package com.healthcarex.hip.saas.mybatis.service.impl;

import com.healthcarex.hip.saas.common.model.SysConfig;
import com.healthcarex.hip.saas.mybatis.dao.ConfigDao;
import com.healthcarex.hip.saas.mybatis.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author chenpan
 * @ClassName: SysConfigServiceImpl
 * description:
 * @date 2018-05-18 15:13
 */
@Service
public class SysConfigServiceImpl extends BaseServiceImpl<SysConfig> implements ISysConfigService {

    @Autowired
    private ConfigDao configDao;

    @Override
    @CacheEvict(value = "config", key = "#p0.configId")
    public int updateNotNull(SysConfig entity) {
        return super.updateNotNull(entity);
    }

    @Override
    @Cacheable(value = "config", key = "#p0")
    public List<SysConfig> findConfigByConfigId(Integer configId) {
        Example example = new Example(SysConfig.class);
        example.createCriteria().andEqualTo("configId", configId);
        return configDao.selectByExample(example);
    }
}
